import pymysql
# 调用env.py文件中的变量连接数据库
from env import MYSQL_HOST
from env import MYSQL_DATABASE
from env import MYSQL_PASSWORD
from env import MYSQL_USERNAME

MYSQL_HOST = MYSQL_HOST
MYSQL_DATABASE = MYSQL_DATABASE
MYSQL_USERNAME = MYSQL_USERNAME
MYSQL_PASSWORD = MYSQL_PASSWORD
connection = pymysql.connect(user=MYSQL_USERNAME,
                             password=MYSQL_PASSWORD,
                             host=MYSQL_HOST,
                             database=MYSQL_DATABASE)

cursor = connection.cursor()

sql = "update user " \
      "set user_name='hanmei', " \
      "user_email='13254678854', " \
      "user_password='aax'" \
      "where id = 3"
result = cursor.execute(sql)
print(result)

connection.commit()
